//
//  Book.m
//  RunLoopDemo
//
//  Created by zhangjikuan on 2020/9/23.
//  Copyright © 2020 hsgd. All rights reserved.
//

#import "Book.h"

@implementation Book

- (id)copyWithZone:(NSZone *)zone {
    Book *bk = [[[self class] allocWithZone:zone] init];
    bk.title = self.title;
    bk.autoher = self.autoher;
    bk.isPublish = self.isPublish;
    return  bk;
}

#pragma mark -- encoder
- (instancetype)initWithCoder:(NSCoder *)coder
{
    self = [super init];
    if (self) {
        self.title = [coder decodeObjectForKey:@"title"];
        self.autoher = [coder decodeObjectForKey:@"author"];
        self.isPublish = [coder decodeBoolForKey:@"isPublished"];
    }
    return self;
}

- (void)encodeWithCoder:(NSCoder *)coder {
    [coder encodeObject:self.title forKey:@"title"];
    [coder encodeObject:self.autoher forKey:@"autoher"];
    [coder encodeBool:self.isPublish forKey:@"isPublish"];

}

+ (BOOL)supportsSecureCoding {
    return  YES;
}
@end
